﻿using System;
using System.Windows.Forms;
using Resources;
using TorchlightModOverseer;
using TorchlightModOverseer.Commands;
using WinFormsCommands;

namespace TorchlightModOverseer
{
	static class Program
	{
		static CommandProcessor Processor;

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			Application.SetCompatibleTextRenderingDefault(false);

			Application.ThreadException += (s, e) =>
			{
				MainWindow sender = (MainWindow)s;
				var errorWin = new AppError();
				errorWin.Left = 0;
				errorWin.Top = 0;
				errorWin.ErrorMessage.Text = e.Exception.ToString();
				sender.Controls.Clear();
				sender.Controls.Add(errorWin);
			};

			ResourceManager.Init();
			Processor = new CommandProcessor(typeof(MainWindow), typeof(MainWindow).Assembly, new StartupCommand());
			Processor.Start();

		}
	}
}
